<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <my-cpn></my-cpn>
    </div>

    <script src="../js/vue.js"></script>
    <template id="myCpn">
        <div>
            我是子组件
            <button @click="getFather">向父组件主动拿数据</button>
        </div>
    </template>
    <script>
        const app = new Vue({
            el:'#app',
            data(){
                return { 
                    msg:'我是父组件中的值'
                }
            },
            components:{
                'my-cpn':{
                    template:'#myCpn',
                    methods:{
                        getFather(){
                            console.log(this.$parent.msg)
                        }
                    }
                }
            }
        })
    </script>
</body>
</html>